When the solenoid valve is assembled, the sealing and connection between the pole piece and the coil and/or the pole piece and the valve housing is normally effected using an O-ring which has been inserted beforehand into a circumferential groove in one of the two components to be connected.